package me.leiusual.sharing.ui.shop

import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.Transformations.switchMap
import androidx.lifecycle.ViewModel
import me.leiusual.sharing.pref.Store
import me.leiusual.sharing.repository.UserRepository
import me.leiusual.sharing.repository.model.Data
import me.leiusual.sharing.util.extension.toLiveData
import javax.inject.Inject

/**
 * author: leiusual
 * create on: 2019-08-10
 * description:
 */
class ShopManageViewModel @Inject constructor(
    private val userRepository: UserRepository,
    val store: Store
) : ViewModel() {

  // 可管理的店铺列表

  private val _userStoreList = MutableLiveData<Unit>()
  val userStoreList: LiveData<Data<Map<Long, String>>> = switchMap(_userStoreList) {
    userRepository.userStoreList().toLiveData()
  }

  fun userStoreList() {
    _userStoreList.value = Unit
  }
}